home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / Reference / DevCon / Orlando_1993 / Devcon93.4 / Networking2 / SANA2 / examples / slip_device.asm < prev    next >
Encoding:
Assembly Source File  |  1993-01-11  |  3.2 KB  |  183 lines

  1. **
  2. ** $Source: hog:Other/networking/sana2/src/slip/RCS/slip_device.asm,v $
  3. ** $State: Exp $
  4. ** $Revision: 37.3 $
  5. ** $Date: 92/08/25 16:42:36 $
  6. ** $Author: kcd $
  7. **
  8. ** Amiga SANA2 Example SLIP Device Driver
  9. **
  10. ** (C) Copyright 1992 Commodore-Amiga, Inc.
  11. **
  12.  
  13.  
  14.     SECTION    firstsection
  15.  
  16.     NOLIST
  17.  
  18.     include    "exec/types.i"
  19.     include    "exec/devices.i"
  20.     include    "exec/initializers.i"
  21.     include    "exec/memory.i"
  22.     include    "exec/resident.i"
  23.     include    "exec/io.i"
  24.     include    "exec/ables.i"
  25.     include    "exec/errors.i"
  26.     include    "exec/tasks.i"
  27.     include    "utility/tagitem.i"
  28.     include    "dos/dos.i"
  29.     include    "dos/dosextens.i"
  30.     include    "dos/dostags.i"
  31.     include    "devices/serial.i"
  32.     include    "devices/sana2.i"
  33.     include    "slip_device.i"
  34.         include "slip_rev.i"
  35.  
  36.     LIST
  37.  
  38. ABSEXECBASE    EQU    4    ;Absolute location of the pointer to exec.library base
  39. **
  40. ** First executable location
  41. **
  42.  
  43. FirstAddress:
  44.     moveq    #-1,d0
  45.     rts
  46.  
  47. SLIPPRI   EQU   5
  48.  
  49.     XREF    EndCode
  50.  
  51. initDDescrip:
  52.                     ; STRUCTURE RT,0
  53.     DC.W    RTC_MATCHWORD        ; UWORD    RT_MATCHWORD (Magic cookie)
  54.     DC.L    initDDescrip        ; APTR    RT_MATCHTAG  (Back pointer)
  55.     DC.L    EndCode            ; APTR    RT_ENDSKIP   (To end of this hunk)
  56.     DC.B    RTF_AUTOINIT        ; UBYTE    RT_FLAGS     (magic-see "Init:")
  57.     DC.B    VERSION            ; UBYTE    RT_VERSION
  58.     DC.B    NT_DEVICE        ; UBYTE    RT_TYPE         (must be correct)
  59.     DC.B    SLIPPRI            ; BYTE    RT_PRI
  60.     DC.L    SLIPName        ; APTR    RT_NAME         (exec name)
  61.     DC.L    idString        ; APTR    RT_IDSTRING  (text string)
  62.     DC.L    Init            ; APTR    RT_INIT
  63.                     ; LABEL    RT_SIZE
  64.  
  65. SLIPName:    SLIPDEVNAME
  66.  
  67. ** This is an identifier tag to help in supporting the device
  68. ** format is 'name version.revision (dd MON yyyy)',<cr>,<lf>,<null>
  69.  
  70. idString:    VSTRING
  71.  
  72. ** Force word alignment
  73.  
  74.     CNOP    0,4
  75.  
  76. Init:
  77.     DC.L    SLIPDev_Sizeof    ; data space size
  78.     DC.L    DevFuncTable    ; pointer to function initializers
  79.     DC.L    0        ; pointer to data initializers (unused)
  80.     DC.L    DevInit        ; routine to run
  81.  
  82. **
  83. ** Standard System Routines
  84. **
  85.  
  86.     XREF    _DevOpen
  87.     XREF    _DevClose
  88.     XREF    _DevExpunge
  89.     XREF    _DevBeginIO
  90.     XREF    _DevAbortIO
  91.  
  92. **
  93. ** Other misc. routines
  94. **
  95.     XDEF    _ExtDeviceBase
  96.     XDEF    _DevProcEntry
  97.     XDEF    @IPToNum
  98.     XDEF    _SANA2BuffCall
  99.     XREF    _DevProcCEntry
  100.  
  101. V_DEF    MACRO
  102.     DC.W    \1+(*-DevFuncTable)
  103.     ENDM
  104.  
  105. DevFuncTable:
  106.     DC.W    -1
  107.     V_DEF    _DevOpen
  108.     V_DEF    _DevClose
  109.     V_DEF    _DevExpunge
  110.     V_DEF    DevReserved
  111.     V_DEF    _DevBeginIO
  112.     V_DEF    _DevAbortIO
  113.     DC.W    -1
  114.  
  115. _ExtDeviceBase    dc.l    0
  116.  
  117. **
  118. ** initRoutine
  119. **
  120. ** Called after device has been allocated.
  121. ** This routine is single threaded
  122. **
  123. ** Register Usage
  124. **
  125. ** a3 - Pointer to temporary RAM
  126. ** a4 - Pointer to expansion.library base
  127. ** d0 - Pointer to device struct
  128. ** a6 - Pointer to Exec Base
  129.  
  130. DevInit:
  131.     movem.l    a0/a5,-(sp)
  132.     movea.l    d0,a5
  133.     move.w    #REVISION,LIB_REVISION(a5)
  134.     move.l    a6,sd_SysLib(a5)
  135.     move.l    a0,sd_SegList(a5)
  136.     lea.l    sd_Lock(a5),a0
  137.     jsrlib    InitSemaphore
  138.     move.l    a5,d0
  139.     movem.l    (sp)+,a0/a5
  140.     rts
  141.  
  142. DevReserved:
  143.     moveq.l    #0,d0
  144.     rts
  145.  
  146. @IPToNum:
  147.     movem.l    d2,-(sp)
  148.     bsr    StrToNum
  149.     lsl.w    #8,d0
  150.     move.w    d0,d2
  151.     bsr    StrToNum
  152.     move.b    d0,d2
  153.     swap    d2
  154.     bsr    StrToNum
  155.     lsl.w    #8,d0
  156.     move.w    d0,d2
  157.     bsr    StrToNum
  158.     move.b    d0,d2
  159.     move.l    d2,d0
  160.     movem.l    (sp)+,d2
  161.     rts
  162.  
  163. StrToNum:
  164.     moveq    #0,d0
  165.     moveq    #0,d1
  166. 1$    move.b    (a0)+,d1
  167.     cmp.b    #'0',d1
  168.     blo    2$
  169.     cmp.b    #'9',d1
  170.     bhi    2$
  171.     sub.b    #'0',d1
  172.     mulu    #10,d0
  173.     add.w    d1,d0
  174.     bra    1$
  175. 2$    rts
  176.  
  177. _DevProcEntry:
  178.     movea.l    _ExtDeviceBase(pc),a6
  179.     jmp    _DevProcCEntry
  180.  
  181. _SANA2BuffCall:
  182.     jmp    (a2)
  183.